<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <input type="file" onchange="audio.call(this)" class="select-file">
    <audio class="audio-node" autoplay></audio>
</body>
</html>
<script>
    // function playMusic () {
    //     if (!this.value) {
    //         return;
    //     }
    //     let fileReader = new FileReader();
    //     let file = this.files[0];
    //     fileReader.onload = function () {
    //         console.log(this.result)
    //         let blob = new Blob([new Int8Array(this.result)]);
    //         console.log(blob)
    //         // 生成一个本地的blob url
    //         const blobUrl = URL.createObjectURL(blob);
    //         // 给audio标签的src属性
    //         document.querySelector('.audio-node').src = blobUrl;
    //     }
    //     fileReader.readAsArrayBuffer(this.files[0]);
    // }
    //
    // (function(context) {
    //     var arr = [1,1];
    //     context.get = function (n) {
    //         if(n === 0 || n === 1){
    //             return n;
    //         }else{
    //             arr[n] = get(n-1) + get(n-2);
    //             return arr[n];
    //         }
    //     }
    // })(window)
    // console.log(get(20))

   function audio(){

      let fileReader = new FileReader();
      let file = this.files[0];
      fileReader.onload = (evt) => {
        const video = document.createElement('video');
        video.src = evt.target.result;
        video.onloadeddata = () => {
          console.log(video)
          // video.remove();
        }
        video.onerror = () => {
          new Error('加载视频出错,请使用正规视频格式~')
        }
      }
      fileReader.readAsDataURL(file);

    }
</script>
